Arithmetic operators perform such familiar mathematical operations as addition or multiplication on the specified operands. Arithmetic operators are restricted to working on numeric VectorScript data types. The table below summarizes the arithmetic operators available in VectorScript.
When - is used as a unary operator preceding a single operand, it performs a negation operation on the operand. That is, it converts a positive value to an equivalently negative value, or it converts a negative value to its equivalently positive value.
The + operator adds two numeric operands. This operator is limited to addition only; unlike in many other languages, this operator may NOT be used to concatenate strings.
The - operator subtracts the second operand from the first. Both operands must be numeric.
The * operator multiplies its two numeric operands.
The / operator divides the first operand by its second operand. The operator performs floating-point division, always returning a value of type
REAL even when both operands are of
INTEGER or
LONGINT type.
The DIV operator divides the first operand by its second operand, always returning a result of type
INTEGER or
LONGINT. The value of
i DIV j is the mathematical quotient of
i/j, rounded down to the nearest
INTEGER or
LONGINT value. For example, the operation
The MOD operator divides the first operand by the second and returns the remainder of the operation as a result of type
INTEGER. For example, the operation
The ^ operator raises the first operand to the power indicated by the second operand; that is,
x^y is equivalent to
x to the
yth power.